<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
</head>
<body>
        <div class="x-body">
            <form class="layui-form layui-form-pane" action="" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发送人
                    </label>
                    <div class="layui-input-block">
                       <input type="text" name="sender" id="sender" required disabled lay-verify="required" autocomplete="off" value="{$names}" class="layui-input">
                    </div>
                </div>

                <br>

                <div class="layui-form-item layui-form-text">
                    <div class="layui-input-block">
                        <textarea name="contents" id="contents" style="display: none;">请输入详细信息</textarea>
                    </div>
                      <label for="L_content" class="layui-form-label" style="top: -2px;">
                          描述
                      </label>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="add" style="float: right; margin-right:50px">发布</button>
                    </div>
                       
                </div>
            </form>
        </div>
  </body>
</html>
  
   <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8"></script>
   <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8"></script>
   <script>
        layui.use(['form','layer'], function(){
              $ = layui.jquery;
              var form = layui.form();
              layer = layui.layer;

              //建立编辑器
              layui.use('layedit', function(){
                   layedit = layui.layedit;
                   indexedit = layedit.build('contents',{
                    hideTool: ['image']
                  }); 
                  layedit.sync(indexedit);
              });

              //监听提交
              form.on('submit(add)', function(data){
                // type=0;
                // sender=$("#sender").val();
                contents = document.getElementById('contents').value=layedit.getContent(indexedit);
                $.post('__URL__/insert',{contents:contents},function(data){
                 
                    if(data=="添加成功"){
                       layer.alert("添加成功", {icon: 6},function () {
                          // 获得frame索引
                          var index = parent.layer.getFrameIndex(window.name);
                          //关闭当前frame
                          parent.layer.close(index);
                          parent.reload();
                       });
                    }else{
                       layer.alert("添加失败", {icon: 6,time:2000},function () {
                            return false;
                       });
                    }
                });
                return false;
            });
        }); 
    </script>
